package cn.linlane.dao.sys;

import cn.linlane.dao.BaseDao;
import cn.linlane.entity.sys.SysRole;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.Set;


public interface SysRoleDao extends BaseDao<SysRole,Integer> {
    /**
     * 编号查询角色
     * @param id
     * @return
     */
    SysRole findSysRoleById(Integer id);

    /**
     * ID查询
     *
     * @param authIds
     * @return
     */
    Set<SysRole> findAllByIdIn(Set<Integer> authIds);

    Boolean existsAllByRoleName(String roleName);

    @Query("select sysRole from SysRole sysRole " +
            "where ( sysRole.name like %?1% or sysRole.roleName like %?1% ) ")
    Page<SysRole> fetchAllBySearchKey(String searchKey, Pageable pageable);
}
